fix(opencode): bound codex stream stalls#29446
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
77ae84c to
04b5394
Compare
04b5394 to
8a781ca
Compare
| return response.json() | ||
| } | ||
|
|
||
| function timeoutController(ms: number) { |
There was a problem hiding this comment.
Out of curiosity, I was looking at some of the other plugins (like github-copilot, etc.) and noticed they also make custom fetch calls during their specific OAuth or authentication flows.
Since these custom authentication fetches aren't wrapped by the new main provider timeout, are they still vulnerable to infinite socket hangs if their respective APIs stall during login? Should we consider abstracting this timeoutController logic so it can be easily applied to all custom provider token/auth fetches?
There was a problem hiding this comment.
@niStee Good catch. I think you’re right.
The new provider timeout protects the actual provider request path, including custom fetch once it’s invoked by the wrapper, but direct auth/token fetch calls inside plugins are outside that protection. So a stalled OAuth/token endpoint can still hang unless that specific call receives/uses a signal or creates its own timeout.
I’d prefer not to broaden this PR too much beyond the Codex timeout bug, but a shared helper for bounded auth fetches makes sense. I can either extract that helper here, or keep this focused and follow up with a small PR applying it across the custom auth flows.
Issue for this PR
Closes #29129
Type of change
What does this PR do?
ChatGPT/Codex OAuth streams can currently sit forever if the upstream request stalls before producing a response, or if an SSE stream stops producing chunks. That leaves the session busy with no visible error.
This PR adds bounded timeouts for that path and lets the existing retry flow recover from those timeout errors. It also avoids relying on
AbortSignal.timeout()for provider request timeouts, since the current wrapper already disables Bun's fetch timeout.How did you verify your code works?
npx --yes bun typecheckfrompackages/opencodenpx --yes bun test test/session/retry.test.tsfrompackages/opencodeScreenshots / recordings
N/A, no UI change.
Checklist